package com.app.xinfadi.widget.dialog;

import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.app.xinfadi.R;
import com.flyco.animation.Attention.Swing;
import com.flyco.dialog.utils.CornerUtils;
import com.flyco.dialog.widget.base.BaseDialog;

/*
审核
 */
public class EndPlanDialog extends BaseDialog<EndPlanDialog> {
    private TextView messageEdt;
    private Button sumbitBtn;
    private String buttonTitle;

    public EndPlanDialog(Context context) {
        super(context);
    }

    public EndPlanDialog(Context context, String buttonTitle) {
        super(context);
        this.buttonTitle = buttonTitle;
    }

    @Override
    public View onCreateView() {
        widthScale(0.85f);
        showAnim(new Swing());
        // dismissAnim(this, new ZoomOutExit());
        View inflate = View.inflate(mContext, R.layout.end_plan_dialog_layout, null);
        sumbitBtn = (Button) inflate.findViewById(R.id.sumbitBtn);
        messageEdt = (TextView) inflate.findViewById(R.id.messageEdt);
        inflate.setBackgroundDrawable(
                CornerUtils.cornerDrawable(Color.parseColor("#ffffff"), dp2px(5)));

        return inflate;
    }

    @Override
    public void setUiBeforShow() {
//        tv_cancel.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                dismiss();
//            }
//        });
        if (!TextUtils.isEmpty(buttonTitle))
            sumbitBtn.setText(buttonTitle);
        sumbitBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (suggestionOnclickListener != null) {
                    suggestionOnclickListener.onClick(v, messageEdt.getText().toString().trim());
                }
                dismiss();
            }
        });
    }

    public SuggestionOnclickListener suggestionOnclickListener;

    public void setSuggestionOnclickListener(SuggestionOnclickListener suggestionOnclickListener) {
        this.suggestionOnclickListener = suggestionOnclickListener;
    }

    public interface SuggestionOnclickListener {
        public void onClick(View v, String suggestion);
    }

}
